package herramientas;

import java.lang.reflect.InvocationTargetException;

import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;



	
  public  class BarThread extends Thread {
    private  int DELAY =0;
   
    JProgressBar progressBar;
	
    
    public BarThread(JProgressBar bar) {
        progressBar = bar;
        
      }
    
    
    public void comenzar(){ 	  	  
    	    
    	   
    	   start();
    	    
    	   
    }
    
   
	

    

    public void run() {
      int minimum = progressBar.getMinimum();
      int maximum = progressBar.getMaximum();
      Runnable runner = new Runnable() {
        public void run() {
       
          int value = progressBar.getValue();
          progressBar.setValue(value + 1);
          
        }
      };
      for (int i = minimum; i < maximum; i++) {
        try {
          SwingUtilities.invokeAndWait(runner);
         
          Thread.sleep(DELAY);
        } catch (InterruptedException ignoredException) {
        } catch (InvocationTargetException ignoredException) {
        }
       
      }
      
      
    }


	public int getDELAY() {
		return DELAY;
	}


	public void setDELAY(int delay) {
		DELAY = delay;
	}
  }

 
